package com.zmzncs.lmtc.module.customer.controller;


import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.customer.pojo.card_record.CardRecordDTO;
import com.zmzncs.lmtc.module.customer.pojo.card_record.CardRecordDurationVO;
import com.zmzncs.lmtc.module.customer.pojo.card_record.CardRecordMonthVO;
import com.zmzncs.lmtc.module.customer.pojo.card_record.CardRecordRechargeVO;
import com.zmzncs.lmtc.module.customer.service.CardRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 客户-月租卡购买记录 前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2020-08-26
 */
@Api(tags = "会员卡购买记录")
@RestController
@RequestMapping("/customer/card-record")
@Validated
public class CardRecordController {

    @Autowired
    CardRecordService cardRecordService;

    @ApiOperation(value = "查询月租卡购买记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "/getMonthCardRecord")
    public Rest<List<CardRecordMonthVO>> getMonthCardRecord() {
        List<CardRecordDTO> cardRecordDTOList = cardRecordService.getMonthCardRecord();

        List<CardRecordMonthVO> cardRecordMonthVOList = JsonUtil.listTransform(cardRecordDTOList, CardRecordMonthVO.class);

        return RestUtil.success(cardRecordMonthVOList);
    }

    @ApiOperation(value = "查询时长卡购买记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "/getDurationCardRecord")
    public Rest<List<CardRecordDurationVO>> getDurationCardRecord() {
        List<CardRecordDTO> cardRecordDTOList = cardRecordService.getDurationCardRecord();

        List<CardRecordDurationVO> cardRecordDurationVOList = JsonUtil.listTransform(cardRecordDTOList, CardRecordDurationVO.class);

        return RestUtil.success(cardRecordDurationVOList);
    }

    @ApiOperation(value = "查询充值记录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "/getRechargeCardRecord")
    public Rest<List<CardRecordRechargeVO>> getRechargeCardRecord() {
        List<CardRecordDTO> cardRecordDTOList = cardRecordService.getRechargeCardRecord();

        List<CardRecordRechargeVO> cardRecordRechargeVOList = JsonUtil.listTransform(cardRecordDTOList, CardRecordRechargeVO.class);

        return RestUtil.success(cardRecordRechargeVOList);
    }
}

